<?php require_once "menu.php"; ?>
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="menudottedline" width="40%"><div class="pathway"></div></td>
        <td class="menudottedline" align="right">
            <table cellpadding="0" cellspacing="0" border="0" id="toolbar">
                <tr height="60" valign="middle" align="center">
                    <td>
                        <a class="toolbar" href="javascript: document.getElementById('flag').value='back'; submitthis();">
                        <?php echo $html->image('admin/restore_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Back
                        </a>
                    </td>
                    <td>
                        <a class="toolbar" href="#">
                        <?php echo $html->image('admin/help_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Help
                        </a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<br>
<br>
<div align="center" class="centermain">
    <div class="main">

        <table class="adminheading">
            <tr>
                <th class="info" rowspan="2" nowrap>Ticket Response</th>
            </tr>
        </table>

        <form id="ticketForm" name="ticketForm" action="<?php echo $html->url('/ticket/ticketresponse/'.$ticketId); ?>" method="post">
            <table class="adminform" cellpadding="20">
                <tr>
                    <th colspan="4">&nbsp;</th>
                </tr>
                <tr>
                    <td colspan="4" class="subheader">
                        <label>Ticket Information</label>
                    </td>
                </tr>
                <tr>
                    <td width="60%" valign="top">
                        <table class="adminlist" cellpadding="20">
                            <tr>
                                <td colspan="2">Action</td>
                            </tr>
                            <tr>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;" colspan="2">
                                    <textarea id="action_taken" name="data[action][action_taken]" style="width: 100%;" title="" class=""></textarea>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">Recommendation</td>
                            </tr>
                            <tr>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;" colspan="2">
                                    <textarea id="recommendation" name="data[action][recommendation]" style="width: 100%;" title="" class=""></textarea>
                                </td>
                            </tr>
                            <tr>
                                <td>&nbsp;</td>
                                <td>
                                    <input type="submit" value="Update" name="button" class="button" style="width: 120px; height: 30px;">&nbsp;
                                    <input type="submit" value="Resolved" name="button" class="button" style="width: 120px; height: 30px;">
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td width="40%" valign="top">
                        <table class="adminlist" cellpadding="20">
                            <tr>
                                <td width="100px">Ticket Number:</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $ticketId; ?>
                                </td>
                            </tr>
                            <tr>
                                <td width="100px">Date Created</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo date('M d, Y', strtotime($data['date_added'])); ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Date Reported</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo date('M d, Y', strtotime($data['date_reported'])); ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Category</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $data['category']['Extra']['value']; ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Item</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $data['item']['Extra']['value']; ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Department</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $data['department']['Extra']['value']; ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Location</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $data['location']['Extra']['value']; ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Subject</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $data['subject']; ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label" valign="top">Details</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;" valign="top">
                                    <p align="left"><?php echo $data['details']; ?></p>
                                </td>
                            </tr>
                        </table>
                        <table class="adminlist">
                            <tr>
                                <th>Responses</th>
                            </tr>
                            <tr>
                                <td>
                                    <div id="accordion">
                                    <?php
                                     if ($ticket_details) {
                                        foreach($ticket_details as $v){
                                     ?>
                                     	<h3><a href="#"><?php echo date('M d, Y', strtotime($v['TicketDetail']['date_taken_action']))?></a></h3>
                                    	<div>
                                    		<p align="left">
                                    		  <label>Action</label>
                                    		  <p align="left"><?php echo $v['TicketDetail']['action_taken']?></p>
                                            </p>
                                    		<p align="left">
                                    		  <label>Recommendation</label>
                                    		  <p align="left"><?php echo $v['TicketDetail']['recommendation']?></p>
                                            </p>
                                    	</div>
                                    <?php
                                        }
                                     }
                                     ?>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            <input type="hidden" name="data[action][ticketDetailId]" value="<?php echo $ticketDetailId; ?>" />
        </form>

    </div>
</div>

<script type="text/javascript">
        tinyMCE.init({
        	// General options
        	mode : "textareas",
        	theme : "advanced",
        	plugins : "table,inlinepopups",

        	// Theme options
        	theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,|,table,removeformat,code",
        	theme_advanced_buttons2 : "",
        	theme_advanced_buttons3 : "",
        	theme_advanced_buttons4 : "",
        	theme_advanced_toolbar_location : "top",
        	theme_advanced_toolbar_align : "left",
        	theme_advanced_statusbar_location : "bottom",
        	theme_advanced_resizing : true,

        	// Example content CSS (should be your site CSS)
        	content_css : "/js/tinymce/examples/css/content.css",

        	// Style formats
        	style_formats : [
        		{title : 'Bold text', inline : 'b'},
        		{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
        		{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
        		{title : 'Example 1', inline : 'span', classes : 'example1'},
        		{title : 'Example 2', inline : 'span', classes : 'example2'},
        		{title : 'Table styles'},
        		{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
        	],

        	formats : {
        		alignleft : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'left'},
        		aligncenter : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'center'},
        		alignright : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'right'},
        		alignfull : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'full'},
        		bold : {inline : 'span', 'classes' : 'bold'},
        		italic : {inline : 'span', 'classes' : 'italic'},
        		underline : {inline : 'span', 'classes' : 'underline', exact : true},
        		strikethrough : {inline : 'del'},
        		customformat : {inline : 'span', styles : {color : '#00ff00', fontSize : '20px'}, attributes : {title : 'My custom format'}}
        	}
        });

	$(function() {
		$("#accordion").accordion({
			icons: {
    			header: "ui-icon-circle-arrow-e",
   				headerSelected: "ui-icon-circle-arrow-s"
			}
        });
	});

    function checkmsg()
    {
        var msg = '<?php echo $msg; ?>';
        if (msg) {
            alert(msg);
        }
    }
    checkmsg();
</script>